package com.product.system.controller;

import com.product.system.domain.FactoryPosts;
import com.product.system.domain.FactoryStorage;
import com.product.system.domain.GoodsAndReceipt;
import com.product.system.domain.PostList;
import com.product.system.service.FactoryAndPostsService;
import com.product.system.utils.Result;
import jnr.ffi.annotations.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("factoryAndPosts")
public class FactoryAndPostsController {

    @Autowired
    FactoryAndPostsService factoryAndPostsService;

    //多对多中间表
    @RequestMapping("postsList")
    public Result postsList(){
       List<FactoryPosts> list= factoryAndPostsService.postsList();
       return Result.success(list);
    }

    /**
     * 联系人/负责人
     * @return
     */
    @RequestMapping("responsibility")
    public Result responsibility(){
        List<PostList> list=factoryAndPostsService.responsibility();
        return Result.success(list);
    }


    /**
     * 拒绝签收列表
     * @return
     */
    @RequestMapping("refuseList")
    public Result refuseList(){
        List<GoodsAndReceipt> list= factoryAndPostsService.refuseList();
        return Result.success(list);
    }

    /**
     * 未签收列表
     * @return
     */
    @RequestMapping("receiptList")
    public Result receiptList(){
        List<GoodsAndReceipt> list= factoryAndPostsService.selectReceipt();
        return Result.success(list);
    }

    /**
     * 待签收列表
     * @return
     */
    @RequestMapping("waitForList")
    public Result waitForList(){
        List<GoodsAndReceipt> list= factoryAndPostsService.waitForList();
        return Result.success(list);
    }

    /**
     * 改成已签收状态
     * @param andReceipt
     * @return
     */
    @RequestMapping("signForReceipt")
    public Result signForReceipt(@RequestBody GoodsAndReceipt andReceipt){
        System.out.println(andReceipt);
        factoryAndPostsService.updateReceipt(andReceipt);
        return Result.success();
    }


    /**
     * 改成拒绝签收状态
     * @param andReceipt
     * @return
     */
    @RequestMapping("refuseReceipt")
    public Result refuseReceipt(@RequestBody GoodsAndReceipt andReceipt){
        System.out.println(andReceipt);
        factoryAndPostsService.updateRefuse(andReceipt);
        return Result.success();
    }




}
